package com.zhiyou.hospital.ssh.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * Created by zhouyanchao on 2017/10/16.
 * Descr: 自己封装的日志打印工具，简单的把log4j的logger封装起来，写的时候方法调用更省事儿，也防止引入错误的logger类
 */
public class LogUtil {

	private Logger logger =  null;
	private Class c = null;
	private String name = null;
	public LogUtil(){
		init();
	}
	public LogUtil(Class c){
		this.c = c;
		init();
	}

	public LogUtil(String name){
		this.name = name;
		init();
	}

	private void init(){
		if(c!=null) {
			this.name = c.getName();
		}

		logger = LogManager.getLogger();
	}


	public void t(Object o){
		logger.trace(o);
	}

	public void d(Object o){
		logger.debug(o);
	}

	public void i(Object o){
		logger.info(o);
	}

	public void w(Object o){
		logger.warn(o);
	}

	public void e(Object o){
		logger.error(o);
	}

	public void f(Object o){
		logger.fatal(o);
	}

	/**
	 * Created by zhouyanchao on 2017/10/16
	 * Descr: 直接打印，不经过log4j。在某些方法中调试代码使用
	 *
	 */
	public void p(Object o){
		System.out.println("LogUtil.p:"+o);
	}

}
